<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <style></style>
  </head>
  <body>
    <div>
      <h1>采用事件绑定</h1>
      <h2>采用事件委托</h2>
    </div>
    <ul id="ul">
      <li>x</li>
      <li>j</li>
      <li>q</li>
    </ul>
    <script>
      var list = document.querySelectorAll("li");
      function showTxt(ev) {
        console.log(ev.target.innerHTML);
      }
      for (let item of list) {
        item.onclick = showTxt;
      }

      var oUI = document.getElementById("ul");
      oUI.addEventListener("click", showTxt, true);
    </script>
  </body>
</html>
